import java.util.Comparator;

class Person {

    public int age;
    public String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

}

class nameComparator implements Comparator<Person>{

    @Override
    public int compare(Person o1, Person o2) {
        return o1.name.compareTo(o2.name);
    }
}

public class Test {

    public static void main(String[] args) {


    }
    public static void main1(String[] args) {
        Person person=new Person(17,"xaoming");
        Person person1=new Person(17,"lihua");
        nameComparator nameComparator1=new nameComparator();
        System.out.println(nameComparator1.compare(person, person1));
    }

}
